package belf.migrate.engine.ddl.seq;

import belf.migrate.api.common.DatabaseIdentifier;
import belf.migrate.api.model.QualifiersModel;
import belf.migrate.api.table.schema.Catalog;
import belf.migrate.engine.ddl.AbstractConvertFactory;
import belf.migrate.engine.ddl.BaseDDLConvert;
import belf.migrate.engine.ddl.seq.oracle.Oracle2DMSeqConvert;
import belf.migrate.engine.ddl.seq.oracle.Oracle2KingbaseSeqConvert;
import belf.migrate.engine.ddl.seq.sqlserver.SqlServer2DMSeqConvert;
import belf.migrate.engine.ddl.seq.sqlserver.SqlServer2KingbaseSeqConvert;

public class SeqConvertFactory extends AbstractConvertFactory {

    @Override
    public BaseDDLConvert create(String schema, String objectName, String sql, Catalog sourceCatalog,
                                 Catalog sinkCatalog, QualifiersModel qualifiersModel) {
        String IDENTIFIER = sourceCatalog.name() + "-" + sinkCatalog.name();
        switch (IDENTIFIER) {
            case DatabaseIdentifier.ORACLE + "-" + DatabaseIdentifier.DAMENG:
                return new Oracle2DMSeqConvert(objectName, sql, sourceCatalog, sinkCatalog, schema, qualifiersModel);
            case DatabaseIdentifier.ORACLE + "-" + DatabaseIdentifier.KINGBASE:
                return new Oracle2KingbaseSeqConvert(objectName, sql, sourceCatalog, sinkCatalog, schema, qualifiersModel);
            case DatabaseIdentifier.SQLSERVER + "-" + DatabaseIdentifier.DAMENG:
                return new SqlServer2DMSeqConvert(objectName, sql, sourceCatalog, sinkCatalog, schema, qualifiersModel);
            case DatabaseIdentifier.SQLSERVER + "-" + DatabaseIdentifier.KINGBASE:
                return new SqlServer2KingbaseSeqConvert(objectName, sql, sourceCatalog, sinkCatalog, schema, qualifiersModel);
            default:
                return new BaseDDLConvert(objectName, sql, sourceCatalog, sinkCatalog, schema, qualifiersModel);
        }
    }
}
